package phantri.uit.menunhahang;

import java.io.IOException;
import java.util.Date;

import org.kobjects.isodate.IsoDate;
import org.ksoap2.serialization.Marshal;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

public class MarshalDate implements Marshal{

	public Object readInstance(XmlPullParser xmlpullparser, String arg1, String arg2,
			PropertyInfo arg3) throws IOException, XmlPullParserException {
		return IsoDate.stringToDate(xmlpullparser.nextText(), IsoDate.DATE_TIME);
	}

	public void register(SoapSerializationEnvelope soapserializationenvelope) {
		soapserializationenvelope.addMapping(soapserializationenvelope.xsd,
				"DateTime", Date.class, this);		
	}

	public void writeInstance(XmlSerializer xmlserializer, Object obj)
			throws IOException {
		xmlserializer.text(IsoDate.dateToString((Date) obj, IsoDate.DATE_TIME));		
	}

}
